/**
* @author AlbertDarren
* @contact 2563491540@qq.com
*/
#include <cstdio>
using namespace std;

int change(char gesture)
{
    switch (gesture)
    {
    case 'B':
        return 0;
        break;
    case 'C':
        return 1;
        break;
    case 'J':
        return 2;
        break;
    }

}

int main_1018()
{
    int N;
    char ka,kb;
    scanf("%d",&N);
    getchar();
    char mp[]={'B','C','J'};
    int A[3]={0},B[3]={0};//win draw fail
    int handA[3]={0},handB[3]={0};//B C J
    while (N--)
    {
        scanf("%c %c",&ka,&kb);
        getchar();
        if ((change(ka)+1)%3==change(kb))//A wins,B fails
        {
            ++A[0];
            ++handA[change(ka)];
            ++B[2];
        }
        else if ((change(kb)+1)%3==change(ka))//A fails,B wins
        {
            ++A[2];
            ++handB[change(kb)];
            ++B[0];
        }
        else
        {
            ++A[1];
            ++B[1];
        }
    }
    printf("%d %d %d\n",A[0],A[1],A[2]);
    printf("%d %d %d\n",B[0],B[1],B[2]);
    int idxa=0,idxb=0;
    for (int i=1;i<3 ;++i )
    {
        if(handA[i]>handA[idxa])
        {
            idxa=i;
        }
        if(handB[i]>handB[idxb])
        {
            idxb=i;
        }
    }
    printf("%c %c\n",mp[idxa],mp[idxb]);
	return 0;
}
